import control  # pip install control
import matplotlib.pyplot as plt
import math
import numpy as np

TimeArray = [i*0.001 for i in range(50000)]
α = 1.1
Kp = 2  # 比例系数
Ti = 0.5  # 系数
Td = 1  # 系数
sys = control.tf([α*Kp*Ti*Td+Ti*Td, Kp*Ti+α*Td, 1], [α*Ti*Td, Ti, 0])  # 系统
TimeArray, yout = control.step_response(sys, TimeArray)

plt.title("Simulation")  # 括号当中输入标题的名称
plt.plot(TimeArray, yout, label="Kp=%.1f Ti=%.1f Td=%.1f α=%.1f" %
         (Kp, Ti, Td, α))
plt.legend(loc='best')  # 图列位置，可选best，center等
plt.xlabel('Time(s)')
plt.ylabel('Output')
plt.show()
